library CovertOperations initializer init requires LegacySystem

	private function Trig_Covert_Operations_Conditions takes nothing returns boolean
		return GetLearnedSkill()=='A022'
	endfunction

	private  function Trig_Covert_Operations_Actions takes nothing returns nothing
		local player p = GetTriggerPlayer()
		local integer i = GetConvertedPlayerId(p)

		if GetLearnedSkill()=='A022' then
			call SetPlayerTechResearched(p,'R005',GetPlayerTechCount(p,'R005',true)+1)
			if GetUnitAbilityLevel(GetTriggerUnit(),'A022')==4 then
				set udg_ReloadTime[i] = udg_ReloadTime[i]-1.2
			elseif GetUnitAbilityLevel(GetTriggerUnit(),'A022')==5 and udg_Mode!=3 then
				call DisableTrigger(GetTriggeringTrigger())
			endif
		endif
		set p = null
	endfunction

	private function init takes nothing returns nothing
		local trigger t
		set t = CreateTrigger(  )
		call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_HERO_SKILL )
		call TriggerAddCondition(t, Condition(function Trig_Covert_Operations_Conditions))
		call TriggerAddAction( t, function Trig_Covert_Operations_Actions)
	endfunction

endlibrary